#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<map>

using namespace std;
const int maxn=3e6+10, P=998244353;

inline int read() {
    int x=0, f=1; char c=getchar();
    for(; c<'0'||c>'9'; c=getchar()) if(c=='-') f=0;
    for(; c>='0'&&c<='9'; c=getchar()) x=x*10+c-'0';
    return f?x:-x;
}
inline int add(int x, int y) {x+=y; return x>=P?x-P:x;}
inline int del(int x, int y) {x-=y; return x<0?x+P:x;}

map<string, int> M;
int ans;

void dfs(string s) {
    if(M.find(s)!=M.end()) return;
    M[s]=1; ++ans;
    if(s=="") return;
    int ls=s.size();
    for(int i=0; i<ls-1; ++i) 
        if(!(s[i]=='A'&&s[i+1]=='B')) {
            string nx="";
            for(int j=0; j<ls; ++j)
                if(j!=i&&j!=i+1) nx+=s[j];
            dfs(nx);
        }
}
string s;

int main() {
    freopen("song.in", "r", stdin);
    freopen("song.out", "w", stdout);
   cin>>s;
   int n=s.size();
    if(n<=10) {
        dfs(s);
        printf("%d", ans);
        return 0;
    }
    int fl=1;
    for(int i=0; i<n-1; ++i) fl&=(s[i]!=s[i+1]);
    if(fl) {
        int prt=1;
        for(int i=0; i<n-1; ++i)
            if(s[i]=='B'&&s[i+1]=='A') ++prt;
        printf("%d", prt);
        return 0;
    }
    return 0;
}